package com.xatz.scanner

import android.app.Dialog
import android.content.Context
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import com.xatz.scanner.databinding.DialogCustomBinding

class CustomDialog(context: Context) : Dialog(context, R.style.Theme_AppCompat_Dialog) {

    private val mBinding = DialogCustomBinding.inflate(LayoutInflater.from(context))

    var contextText: String = ""
        set(value) {
            field = value
            mBinding.tvContentText.text = contextText
        }

    init {
        setContentView(mBinding.root)
        mBinding.btnClose.setOnClickListener { dismiss() }
        setCanceledOnTouchOutside(false)
        window?.setLayout(ScreenUtils.getScreenWidth(context) * 3 / 4, ConstraintLayout.LayoutParams.WRAP_CONTENT)
    }

    fun showDialog() {
        show()
    }
}